package com.wujiayu.retry.intercept.register;

import com.wujiayu.retry.intercept.RequestLimitIntercept;
import com.wujiayu.retry.intercept.RequestParamVerifyInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author wujiayu
 * 拦截器注册器
 */
@Slf4j
@Component
public class WebMvcConfig implements WebMvcConfigurer {
    @Autowired
    private RequestLimitIntercept requestLimitIntercept;
    @Autowired
    private RequestParamVerifyInterceptor requestParamVerifyInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.info("添加接口防刷拦截器");
        registry.addInterceptor(requestLimitIntercept);
        log.info("添加接口参数防篡改拦截器");
        //registry.addInterceptor(requestParamVerifyInterceptor).addPathPatterns("/**");
    }
}
